function plotted = PlotWithBreaks(x, y, separation, color, name)
    %cut the x data into blocks
    idx = find(abs(diff(x)) > separation);
    idx = [0, idx, length(x)];
    %for each block, plot it.
    for i = 1:(length(idx)-1)
        if nargin == 5 && i == 1
            name
            plot(x( idx(i)+1 : idx(i+1) ), y( idx(i)+1 : idx(i+1) ), 'color', color, 'MarkerSize', 2, 'MarkerFaceColor', color, 'linewidth', 2, 'DisplayName', name);
        else
            h = plot(x( idx(i)+1 : idx(i+1) ), y( idx(i)+1 : idx(i+1) ), 'color', color, 'MarkerSize', 2, 'linewidth', 2, 'MarkerFaceColor', color);
            hasbehavior(h, 'legend', false);
        end
        hold all;
    end
    plotted = 1;
end